FROM wuyufei1993/jdk:8

#yum aliyun
RUN curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
RUN sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
RUN curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
RUN yum makecache
RUN yum update -y && yum clean all
RUN yum install -y systemd* && yum clean all

#Setting up systemd
ENV container docker
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
VOLUME [ "/sys/fs/cgroup", "/usr/hdp", "/hadoop", "/etc/ambari-agent", "/etc/ambari-metrics-grafana", "/etc/ambari-metrics-monitor", "/etc/ambari-server", "/etc/ams-hbase", "/etc/hadoop", "/etc/hive", "/etc/hive2", "/etc/hive-hcatalog", "/etc/hive-webhcat", "/etc/hst", "/etc/pig", "/etc/ranger", "/etc/ranger-admin", "/etc/ranger-kms", "/etc/ranger-tagsync", "/etc/ranger-usersync", "/etc/slider", "/etc/spark2/", "/etc/sqoop/", "/etc/storm-slider-client", "/etc/tez", "/etc/tez_hive2", "/etc/zookeeper", "/var/run/agent_update.pid", "/var/run/ambari-agent", "/var/run/ambari-metrics-collector", "/var/run/ambari-metrics-monitor", "/var/run/ams-hbase", "/var/run/hadoop", "/var/run/hadoop-hdfs", "/var/run/hadoop-mapreduce", "/var/run/hadoop-yarn", "/var/run/hive", "/var/run/hive2", "/var/run/hive-hcatalog", "/var/run/hst", "/var/run/ranger", "/var/run/spark", "/var/run/spark2", "/var/run/sqoop", "/var/run/webhcat", "/var/run/zookeeper", "/usr/lib/ambari-agent", "/usr/lib/ambari-metrics-collector", "/usr/lib/ambari-metrics-hadoop-sink", "/usr/lib/ambari-metrics-kafka-sink", "/usr/lib/ams-hbase", "/usr/lib/flume", "/usr/lib/storm", "/var/lib/ambari-agent", "/var/lib/ambari-metrics-collector", "/var/lib/hadoop-hdfs", "/var/lib/hadoop-mapreduce", "/var/lib/hadoop-yarn", "/var/lib/hive", "/var/lib/hive2", "/var/lib/ranger", "/var/lib/slider", "/var/lib/smartsense", "/var/lib/spark2", "/var/lib/zookeeper", "/usr/lib/bigtop-utils", "/usr/lib/python2.6/site-packages/" ]
CMD ["/usr/sbin/init"]

RUN yum install -y yum-utils yum-plugin-ovl tar git curl bind-utils unzip wget openssh-server openssh-clients telnet net-tools initscripts ntp which
# Setup sshd
RUN systemctl enable sshd
RUN systemctl enable ntpd
ADD ambari.repo /etc/yum.repos.d/ambari.repo
ADD hdp.gpl.repo /etc/yum.repos.d/hdp.gpl.repo
ADD hdp.repo /etc/yum.repos.d/hdp.repo

RUN \cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
VOLUME [ "/sys/fs/cgroup" ]
#设置密码
RUN echo 'root:Ambari123456@@' | chpasswd
#修改SSH端口
RUN sed -i '/#Port 22/aPort 222' /etc/ssh/sshd_config

RUN yum install -y ambari-agent

ENV AMBARI_SERVER '10.0.0.8'
ADD start-agent.sh /root/start-agent.sh